#!/usr/bin/python
# -*- coding:utf-8 -*-
#梳子排序
#@author : wklken@yeah.net

def comb_sort(l):
    print l
    dis = int(len(l)/1.3)
    while dis:
        print "gap: ",dis
        for i in range(len(l)-dis):
            print "cmp l[%s]=%s,l[%s]=%s"%(i,l[i],i+dis,l[i+dis])
            if l[i] > l[i+dis]:
                l[i], l[i+dis] = l[i+dis], l[i]
                print "change",l
        dis = int(dis/1.3)
        print "one time:",l
        
l = [8, 4, 3, 7, 6, 5, 2, 1]
comb_sort(l)        